/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package xdxn.editor.studio.data;

import java.util.ArrayList;
import xdxn.editor.studio.geom.Vector2D;

/**
 * 对象基类，移动的实现
 *
 * @author Cai Han
 */
public class BaseObject {

    public int id;
    public String name;
    public String tag;

    public int x;
    public int y;
    
    private float __Speed;
    private float __Acceleration_Speed;
    private Vector2D __Speed_Vec2;
    private Vector2D __Dir_Vec2;
    private Vector2D __Acceleration_Speed_Vec2;
    private Vector2D __Acceleration_Dir_Vec2;

    private final ArrayList<BaseObject> __Child_List;
    
    public BaseObject() {
        __Child_List = new ArrayList<>();
    }

    public void Update( float dt ) {

        if ( __Acceleration_Speed != 0 ) {

        }

        if ( __Speed != 0 ) {

        }
        
        for ( BaseObject baseObject : __Child_List ) {
            baseObject.Update(dt);
        }
    }

    public float SetSpeed() {
        return __Speed;
    }

    public void SetSpeed( float _speed ) {
        __Speed = _speed;
        __Speed_Vec2.x = _speed * __Dir_Vec2.x;
        __Speed_Vec2.y = _speed * __Dir_Vec2.y;
    }

    public void SetDirVec2( float x , float y ) {
        __Dir_Vec2.x = x;
        __Dir_Vec2.y = y;
        __Speed_Vec2.x = x * __Speed;
        __Speed_Vec2.y = y * __Speed;
    }

    public float GetAccelerationSpeed() {
        return __Acceleration_Speed;
    }

    public void SetAccelerationSpeed( float _speed ) {
        __Acceleration_Speed = _speed;
        __Acceleration_Speed_Vec2.x = _speed * __Acceleration_Dir_Vec2.x;
        __Acceleration_Speed_Vec2.y = _speed * __Acceleration_Dir_Vec2.y;
    }

    public void SetADirVec2( float _x , float _y ) {
        __Dir_Vec2.x = _x;
        __Dir_Vec2.y = _y;
        __Acceleration_Speed_Vec2.x = _x * __Acceleration_Speed;
        __Acceleration_Speed_Vec2.y = _y * __Acceleration_Speed;
    }
}
